<template>
  <div>
    <div class="uppercase text-sm font-semibold text-gray-600 px-2 mb-2">
      Informations
    </div>
    <Box variant="flat" padding="xs">
      <DescriptionList>
        <DescriptionListItem term="Crée le" :description="$dayjs(territoire.created_at).format('D MMMM YYYY à HH:mm')" />
        <DescriptionListItem term="Modifié le" :description="$dayjs(territoire.updated_at).format('D MMMM YYYY à HH:mm')" />
        <DescriptionListItem term="Nom" :description="territoire.name" />
        <DescriptionListItem term="Type" :description="$options.filters.label(territoire.type,'territoire_types')" />
        <DescriptionListItem v-if="territoire.department" term="Département" :description="`${territoire.department} - ${$options.filters.label(territoire.department, 'departments')}`" />
        <DescriptionListItem v-if="territoire.type === 'city'" term="Zips" :description="territoire.zips.join(', ')" />
        <template v-if="['admin'].includes($store.getters.contextRole)">
          <DescriptionListItemGauge
            term="Tx. complétion"
            :percentage="territoire.completion_rate"
          />
          <DescriptionListItem
            v-if="territoire.missing_fields.length"
            term="Champs manquants"
            :description="territoire.missing_fields.map((option) => $options.filters.label(option, 'territoire_fields')).join(', ')"
          />
        </template>
      </DescriptionList>
    </Box>
  </div>
</template>

<script>
export default {
  props: {
    territoire: {
      type: Object,
      required: true
    }
  }
}
</script>
